// shopPages/cardSales/cardSales.js
var app = getApp()
var data_list=[]
Page({

  /**
   * 页面的初始数据
   */
  data: {
    Shortterm:'',
    Longtime:'',
    Salexq:[],
    page:1,
    datalist:[],
    more_status:false
  },
  bindDateChange: function (e) {
    this.setData({
      start: e.detail.value
    })
  },
  bindDateChange1: function (e) {
    this.setData({
      end: e.detail.value
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    data_list=[];
    var day3 = new Date();
    day3.setTime(day3.getTime());
    var month = day3.getMonth() + 1;
    if (month.toString().length==1){
      month = '0' + month;
    }
    var day = day3.getDate();
    if (day.toString().length == 1) {
      day = '0' + day;
    }
    var start = day3.getFullYear() + "-" + month + "-01";
    var end = day3.getFullYear() + "-" + month + "-" + day;
    that.setData({
      start: start,
      end: end
    });
    that.get_data(start, end,0);
  },
  getData:function(){
    data_list = [];
    this.get_data(this.data.start, this.data.end,1);
  },
  get_data: function (start, end,type_){
    
    const that = this;
    var more_status = that.data.more_status;
    var page = that.data.page;
    if (type_>0){
      page=1;
    }
    wx.showLoading({
      title: '玩命加载中',
    })

    var url2 = '/Manager/order_card_list';
    let params = {
      uid: app.globalData.userInfo.id,
      start: start,
      end: end,
      pageno: page,
      pagesize:10
    };
    app.HttpPostSend(url2, params, function (res) {
      wx.hideLoading();
      if (res.code == 0) {
        app.showTipMsg(res.msg);

      } else {
       
        if (res.data.length < 10) {
          more_status = false;
        } else {
          more_status = true;


          page += 1;
          that.setData({
            page: page,
            
          });
        }
        var list = res.data;
        for (let i = 0; i < list.length; i++) {
          data_list.push(list[i]);
        }
        that.setData({
          datalist: data_list,
          more_status: more_status
        });
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var that = this;
    console.log(that.data.more_status);
    if (that.data.more_status == true) {
      var that = this;
      that.get_data(that.data.start, that.data.end,0);
    }
  },

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})